package com.example.admin.smstest.electric;

import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.TextView;

import com.example.admin.smstest.R;
import com.example.admin.smstest.permission.CheckPermissionsActivity;

/**
 * 获取系统电量Activity
 * Created by admin on 2017/6/5.
 */

public class ElectricQuantity extends CheckPermissionsActivity implements ElectricQuantityReceiver.BRInteraction {

    private TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.text);
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
        ElectricQuantityReceiver receiver = new ElectricQuantityReceiver();
        registerReceiver(receiver, intentFilter);
        receiver.setBRInteractionListener(this);
    }

    @Override
    public void setText(String content) {
        if (content != null) {
            textView.setText(content);
        }
    }
}
